home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / GrowBoxDock / Sources / AboutBox.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-30  |  6.2 KB  |  168 lines

  1. /*
  2.     File:        AboutBox.c
  3.  
  4.     Contains:    About Box support for SimpleText
  5.  
  6.     Version:    Mac OS X
  7.  
  8.     Disclaimer:    IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  9.                 ("Apple") in consideration of your agreement to the following terms, and your
  10.                 use, installation, modification or redistribution of this Apple software
  11.                 constitutes acceptance of these terms.  If you do not agree with these terms,
  12.                 please do not use, install, modify or redistribute this Apple software.
  13.  
  14.                 In consideration of your agreement to abide by the following terms, and subject
  15.                 to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  16.                 copyrights in this original Apple software (the "Apple Software"), to use,
  17.                 reproduce, modify and redistribute the Apple Software, with or without
  18.                 modifications, in source and/or binary forms; provided that if you redistribute
  19.                 the Apple Software in its entirety and without modifications, you must retain
  20.                 this notice and the following text and disclaimers in all such redistributions of
  21.                 the Apple Software.  Neither the name, trademarks, service marks or logos of
  22.                 Apple Computer, Inc. may be used to endorse or promote products derived from the
  23.                 Apple Software without specific prior written permission from Apple.  Except as
  24.                 expressly stated in this notice, no other rights or licenses, express or implied,
  25.                 are granted by Apple herein, including but not limited to any patent rights that
  26.                 may be infringed by your derivative works or by other works in which the Apple
  27.                 Software may be incorporated.
  28.  
  29.                 The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  30.                 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  31.                 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  32.                 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  33.                 COMBINATION WITH YOUR PRODUCTS.
  34.  
  35.                 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  36.                 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  37.                 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38.                 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  39.                 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  40.                 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  41.                 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42.  
  43.     Copyright © 1993-2001 Apple Computer, Inc., All Rights Reserved
  44. */
  45.  
  46. #include "MacIncludes.h"
  47.  
  48. #include "AboutBox.h"
  49.  
  50.  
  51. // --------------------------------------------------------------------------------------------------------------
  52. // INTERNAL ROUTINES
  53. // --------------------------------------------------------------------------------------------------------------
  54. static void DrawCenteredStringAt(Str255 theString, short yLocation)
  55. {
  56.     Rect    portRect;
  57.     CGrafPtr thePort = GetQDGlobalsThePort();
  58.  
  59.     GetPortBounds(thePort, &portRect);
  60.     
  61.     MoveTo(portRect.left + ((portRect.right-portRect.left) >> 1) -
  62.                             (StringWidth(theString) >> 1), yLocation);
  63.     DrawString(theString);
  64.     
  65. } // DrawCenteredStringAt
  66.  
  67. // --------------------------------------------------------------------------------------------------------------
  68. // OOP INTERFACE ROUTINES
  69. // --------------------------------------------------------------------------------------------------------------
  70.  
  71. static OSStatus    AboutUpdateWindow(WindowPtr pWindow, WindowDataPtr pData)
  72. {
  73. #pragma unused (pData)
  74.  
  75.     Str255        theString;
  76.         Rect        bounds;
  77.  
  78.     // type style for application name
  79.     TextFont(systemFont);
  80.     TextSize(12);
  81.     
  82.     // name of application
  83.     GetIndString(theString, kAboutStrings, 1);
  84.     DrawCenteredStringAt(theString, 32);
  85.     
  86.     // type style for all others
  87.     TextFont(applFont);
  88.     TextSize(9);
  89.     
  90.     // author names
  91.     GetIndString(theString, kAboutStrings, 2);
  92.     DrawCenteredStringAt(theString, 50);
  93.     GetIndString(theString, kAboutStrings, 3);
  94.     DrawCenteredStringAt(theString, 65);
  95.     GetIndString(theString, kAboutStrings, 4);
  96.     DrawCenteredStringAt(theString, 80);
  97.     
  98.     // copyright, on the left
  99. //    GetIndString(theString, kAboutStrings, 5);
  100. //    MoveTo(10, 105);
  101. //    DrawString(theString);
  102.     
  103.     // version, on the right
  104. //    GetIndString(theString, kAboutStrings, 6);
  105.  //       MoveTo((GetWindowPortBounds(pWindow, &bounds)->right - 10) - StringWidth(theString), 105);
  106. //    DrawString(theString);
  107.     
  108.     return noErr;
  109.     
  110. } // AboutUpdateWindow
  111.  
  112. // --------------------------------------------------------------------------------------------------------------
  113.  
  114. static OSStatus    AboutGetBalloon(WindowPtr pWindow, WindowDataPtr pData, 
  115.         Point *localMouse, short * returnedBalloonIndex, Rect *returnedRectangle)
  116. {
  117. #pragma unused (pWindow, pData, localMouse, returnedRectangle)
  118.  
  119.     *returnedBalloonIndex = iNoBalloon;
  120.     
  121.     return noErr;
  122.     
  123. } // AboutGetBalloon
  124.  
  125. // --------------------------------------------------------------------------------------------------------------
  126.  
  127. static OSStatus    AboutKeyEvent(WindowPtr pWindow, WindowDataPtr pData, EventRecord *pEvent, Boolean isMotionKey)
  128. {
  129.     #pragma unused(pWindow, pData, pEvent, isMotionKey)
  130.  
  131.     return noErr;
  132.  
  133. } // AboutKeyEvent
  134.  
  135. // --------------------------------------------------------------------------------------------------------------
  136.  
  137. static OSStatus    AboutMakeWindow(WindowPtr pWindow, WindowDataPtr pData)
  138. {
  139. #pragma unused (pWindow)
  140.  
  141.     pData->pUpdateWindow = (UpdateWindowProc)    AboutUpdateWindow;
  142.     pData->pGetBalloon     = (GetBalloonProc)        AboutGetBalloon;
  143.     pData->pKeyEvent     = (KeyEventProc)        AboutKeyEvent;
  144.  
  145.     return noErr;
  146.     
  147. } // AboutMakeWindow
  148.  
  149. // --------------------------------------------------------------------------------------------------------------
  150.  
  151. OSStatus    AboutPreflightWindow(PreflightPtr pPreflightData)
  152. {
  153.     pPreflightData->resourceID         = kAboutWindowID;
  154.     pPreflightData->continueWithOpen     = true;
  155.     pPreflightData->makeProcPtr         = (MakeWindowProc) AboutMakeWindow;
  156.     
  157.     return noErr;
  158.     
  159. } // AboutPreflightWindow
  160.  
  161. // --------------------------------------------------------------------------------------------------------------
  162.  
  163. void AboutGetFileTypes(OSType * pFileTypes, OSType * pDocumentTypes, short * numTypes)
  164. {
  165. #pragma unused (pFileTypes, pDocumentTypes, numTypes)
  166.  
  167. } // AboutGetFileTypes
  168.